package com.tedu.lingmaagent.controller;

import com.tedu.lingmaagent.domain.Appointment;
import com.tedu.lingmaagent.service.AppointmentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;

@Tag(name = "医院模块")
@Controller
@ResponseBody
@RequestMapping("/hospital")
public class AppointmentController {

    @Autowired
    private AppointmentService appointmentService;

    @Operation(summary = "预约信息")
    @GetMapping("/appointment")
    public String  appointments(){
        List<Appointment> list = appointmentService.list();
        System.out.println(list);

        return list.toString() ;
    }

    @Operation(summary = "取消预约")
    @GetMapping("/cancelAppointment")
    public String cancelAppointment(@RequestParam("idCard") String idCard,
                                    @RequestParam("date") String date,
                                    @RequestParam("time") String time,
                                    @RequestParam("department") String department) {
        if (appointmentService.cancelAppointment(idCard, date, time, department)) {
            return "预约取消成功😀";
        }
        return "预约取消失败，未找到对应的预约信息😔";
    }
}

